﻿@page
@inherits Acesoft.Web.UI.RazorPages.WebPageBase
@inject IConfigService ConfigService
@{
    Layout = "_shared/site";
    Ace.RenderAuthOptions = true;

    var cfg = ConfigService.GetConfig(1);
    ViewData["Title"] = "登录";

    var success =  Ace.AC.WeChatAuthorize(Membership.Auth_OpenID);
}
@if (success)
{
    <link rel="stylesheet" href="~/scripts/swiper/dist/css/swiper.min.css">
    <script src="~/scripts/swiper/dist/js/swiper.min.js"></script>
    <div class="swiper-container" style="height:440px">
        <div class="swiper-wrapper">
            @foreach (var photo in cfg["sys_login_photos"].Split('|'))
            {
                <div class="swiper-slide" style="background-image:url(@photo)"></div>
            }
        </div>
        <div style="position:absolute;left:0;right:0;top:0;z-index:9999">
            <div class="container">
                <div class="col-sm-6 col-sm-offset-6 col-md-4 col-md-offset-8">
                    <div style="margin:50px 0;padding:30px;background:#fff;opacity:0.90">
                        <h3 style="color:#08c">平台登录</h3>
                        @{
                            Ace.Form().Id("log").Ajax(a => a.RouteQuery("ReturnUrl").HttpPost("auth", "login")).Content(
                                @<div class="pt15">
                                    @if (Ace.AC.Logined)
                                    {
                                        <div class="pt20 ft16 lh35">
                                            欢迎您，<span style="color:#09c;font-weight:bold">@Ace.AC.User.NickName</span>！
                                        </div>
                                        <div class="pt15 ft16 lh35">
                                            本次于 @Ace.AC.User.DLogin.Value.ToString("yyyy-MM-dd HH:mm") 登录！
                                        </div>
                                        <div class="pt25">
                                            <a class="btn btn-primary" style="width:100%" onclick="AX.enter()">进入</a>
                                        </div>
                                        <div class="pt15">
                                            <a class="btn btn-success" style="width:100%" onclick="AX.logout()">注销</a>
                                        </div>
                                    }
                                    else
                                    {
                                        <div class="pt15">
                                            @Ace.TextBox().Name("username").Required().IconCls("icon-man").IconAlign(Align.left).IconWidth(30).Width("100%").Height(35)
                                        </div>
                                        <div class="pt15">
                                            @Ace.PasswordBox().Name("password").Required().IconCls("icon-lock").IconAlign(Align.left).IconWidth(30).Width("100%").Height(35).ShowEye(false)
                                        </div>
                                        <div class="pt15">
                                            @Ace.CheckBox().Name("persistent").Text("保持登录状态").Checked().Value("true")
                                            <span class="fr">
                                                @*<a href="regist">用户注册</a>*@
                                            </span>
                                        </div>
                                        <div class="pt15">
                                            @Html.AntiForgeryToken()
                                            <a class="btn btn-primary" style="width:100%" onclick="login()">登录</a>
                                        </div>
                                        <div class="pt15">
                                            <a href="backpwd">忘记密码</a>
                                        </div>
                                    }
                                </div>
                            ).Render();
                        }
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
        function login() {
            AX.formSubmit('#log', function (rv) {
                $.messager.info({ msg: '登录成功' });
                var url = AX.query('ReturnUrl') || ('/plat/account/enter?x=' + AX.tick());
                window.location = url;
            });
        }
        new Swiper('.swiper-container', { direction: 'vertical', loop: true, autoplay: true });
        if (window.parent != window) {
            window.parent.location = '/plat/account/login';
        }
    </script>
}
else
{
    <div class="p30 text-c ft25 cr-a" style="min-height:500px">非法访问，微信内请从菜单进入！</div>
}